<?php
// 404 header
header("HTTP/1.1 404 Not Found");

// check if async request
$bAjaxRequest = FALSE;
if ( isset ($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest"){
    $bAjaxRequest = TRUE;
}

if ($bAjaxRequest === FALSE){
// print html version of the error
print <<< EOD
<html>
<head>
<title>404 Page Not Found</title>
<style type="text/css">

body {
background-color:	#fff;
margin:				40px;
font-family:		Lucida Grande, Verdana, Sans-serif;
font-size:			12px;
color:				#000;
}

#content  {
border:				#999 1px solid;
background-color:	#fff;
padding:			20px 20px 12px 20px;
}

h1 {
font-weight:		normal;
font-size:			14px;
color:				#990000;
margin: 			0 0 4px 0;
}
</style>
</head>
<body>
	<div id="content">
		<h1>$heading</h1>
		$message
	</div>
</body>
</html>
EOD;
  
}else if($bAjaxRequest === TRUE){
    // print json version of the error
    $aError = array(
        "error" => TRUE,
        "type" => 404,
        "description" => ($message)
    );
    echo json_encode($aError);
}
/* End of file error_404.php*/